To save the current graphics port (basic, color, or offscreen) and the current GDevice record, use the GetGWorld procedure. To change the current graphics port (basic, color, or offscreen), use the SetGWorld procedure; any drawing your application performs then occurs in this graphics port.
You can use the GetGWorldDevice function to obtain a handle to the GDevice record associated with an offscreen graphics world.
To save the current graphics port (basic, color, or offscreen) and the current GDevice record, use the GetGWorld procedure.
PROCEDURE GetGWorld (VAR port: CGrafPtr; VAR gdh: GDHandle);
The GetGWorld procedure returns a pointer to the current graphics port in the port parameter. This parameter can return values of type GrafPtr , CGrafPtr , or GWorldPtr , depending on whether the current graphics port is a basic graphics port, color graphics port, or offscreen graphics world. The GetGWorld procedure returns a handle to the GDevice record for the current device in the gdh parameter.
After using GetGWorld to save a graphics port and a GDevice record, your application can later use the SetGWorld procedure, described next, to restore them.
The GetGWorld procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.
Listing 6-1 and Listing 6-2 illustrate how to use the GetGWorld procedure to save the current graphics port for an active window, the SetGWorld procedure to change the current graphics port to an offscreen graphics world, and then SetGWorld again to restore the active window as the current graphics port.
To change the current graphics port (basic, color, or offscreen), use the SetGWorld procedure.
PROCEDURE SetGWorld (port: CGrafPtr; gdh: GDHandle);
The SetGWorld procedure sets the current graphics port to the one specified by the port parameter and--unless you set the current graphics port to be an offscreen graphics world--sets the current device to that specified by the gdh parameter.
In the port parameter, you can specify values of type GrafPtr , CGrafPtr , or GWorldPtr , depending on whether you want to set the current graphics port to be a basic graphics port, color graphics port, or offscreen graphics world. Any drawing your application performs then occurs in this graphics port.
The SetGWorld procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.
Listing 6-1 and Listing 6-2 illustrate how to use the GetGWorld procedure to save the current graphics port for an active window, the SetGWorld procedure to change the current graphics port to an offscreen graphics world, and then SetGWorld again to restore the active window as the current graphics port.
Use the GetGWorldDevice function to obtain a handle to the GDevice record associated with an offscreen graphics world.
FUNCTION GetGWorldDevice (offscreenGWorld: GWorldPtr): GDHandle;
The GetGWorldDevice function returns a handle to the GDevice record associated with the offscreen graphics world specified by the offscreenGWorld parameter. In this parameter, supply the pointer returned to your application by the NewGWorld function when you created the offscreen graphics world. If you created the offscreen world by specifying the noNewDevice flag, the GDevice record is for one of the screen devices or is the GDevice record that you specified to NewGWorld or UpdateGWorld .
Note: QuickTime 3 for Windows does not support the noNewDevice flag.If you point to a GrafPort or CGrafPort record in the offscreenGWorld parameter, GetGWorldDevice returns the current device.